// TOWN SCRIPT
//    Town 5: Portal Clearing

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documentation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

body;

beginstate INIT_STATE;
// Called upon entering
if(get_flag(3,2) == 0) {
	reset_dialog();
	add_dialog_str(0,"You finally reach the end of this mountainous pass. In front of you, before the sheer cliff wall, is a raised platform. Tall stones have been placed in a circle upon it, with elaborate runes seared into the ground between them.",0);
	add_dialog_str(1,"The air up here crackles - this must be the teleportal device that the book under Greenleaf mentioned. Presumably, all you have to do is walk into it...",0);
	add_dialog_str(2,"Other than the portal, there is nothing up here but dust and the bleached bones of small animals. It is completely and eerily silent - a far cry from the warmth and vibrance of the Valley below.",0);
	run_dialog(1);
	set_flag(3,2,1);
}

break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// Called every turn.

break;

//Appraching portal
beginstate 10;

	if(is_combat() == 1) {
		block_entry(1);
		print_str_color("You can't enter the portal in combat mode.",3);
		end();
		}
		
	reset_dialog();
	add_dialog_str(0,"You approach the centre of the raised platform nervously - the air is crackling keenly with magical energy. As you draw near, small balls of light begin forming over the central rune. Do you step closer?",0);
	add_dialog_choice(0,"Stay put.");
	add_dialog_choice(1,"Step closer.");
	if(run_dialog(1) == 1) {
		block_entry(1);
	} else {
		message_dialog("You step onto the central rune. For a moment, nothing seems to happen. Then, suddenly, you feel the energy in the air envelope you, pour over you, *into* you.","You begin to feel faint, as if you aren't completely solid, but in fact, just an extension of the energy. Then you pass out...");
		put_boom_on_char(0,2,0);
		put_boom_on_char(1,2,0);
		put_boom_on_char(2,2,0);
		put_boom_on_char(3,2,0);
		run_animation_sound(10);
		move_to_new_town(3,17,13);
	}
break;

//Boulders
beginstate 11;
	message_dialog("You look at this boulder - it crackles menacingly as you lean closer. You aren't sure whether or not the material is magically-charged, or if somebody put an enchantment onto it later.","You ponder this for a second, before moving on. As interesting as it is, you have better things to occupy your mind.");
break;

//Rune
beginstate 12;
	if(get_flag(3,1) == 0) {
		set_terrain(16,17,459);
		set_flag(3,1,1);
	}
break;